<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/jsp/taglib.jsp" %>
<%@page import="com.biz.model.Singleton.ZkNode" %>
<%@ page import="com.framework.utils.ConfigUtil" %>
<%@ page import="com.biz.conf.Global" %>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>扫码核券</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
    <link rel="shortcut icon" href="favicon.ico"> <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>

    <style>
        table.shuxtable tr td{
            padding:5px 0;
        }

        .dtupload > img {
            width: 54px;
            padding-left: 39px;
            padding-top: 16px;
        }

        .dtupload > a {
            color: #268eff;
            font-size: 12px;
            position: relative;
            left: 26px;
            top: 10px;
        }

        .dtupload > a:hover,
        .shoplogo > a:hover {
            color: #F93;
        }

        .upload_pic {
            height: 70px;
            width: 70px;
            position: relative;
            cursor: pointer;
            color: #ccbe9e;
            background: #fff;
            overflow: hidden;
            display: inline-block;
            *display: inline;
            *zoom: 1;
        }

        .upload_pic input {
            position: absolute;
            height: 100%;
            width: 100%;
            right: 0;
            top: 0;
            opacity: 0;
            filter: alpha(opacity=0);
            cursor: pointer
        }

        .upload_pic:hover {
            color: #ccbe9e;
            background: #fff;
            text-decoration: none
        }
        .toplinesave{
            padding: 10px;
            border-bottom:1px solid #d9d9d9;
        }
        .mainmidlist{
            padding: 10px 0;
        }
        .paddingnone{
            padding:0;
        }
        .martopcancel{
            margin-top: 20px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12" style="background-color: #fff;">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>关注回复</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="col-sm-12 text-right toplinesave">
                        <a href="javascript:void(0);" class="btn btn-primary" onclick="addList()" target="_self">新增</a>
                        <a href="javascript:void(0);" class="btn btn-primary" onclick="doSave()" target="_self">保存</a>
                    </div>
                    <form id="form"  name="form">
                        <input type="hidden" id="count" name="pbrand.count">
                        <div class="col-sm-12 "  style="max-height:350px;overflow-y:auto;" id="divForm">
                            <div class="col-sm-12 mainmidlist" id="div1">
                                <div class="col-sm-3">
                                    <!--上传logo-->
                                    <div class="dtupload">
                                        <a href="javascript:" class="upload_pic" style="height:80px;"><input type="file" name="fileToUpload" id="fileToUpload1" onChange="uploadFile('fileToUpload1','imgUpdate1','shopPicId1');">
                                            <img id="imgUpdate1" src="${OSSURL}/common/plus_72.png" width="100%"/>
                                            <input type="hidden" id="shopPicId1" name="pbrand.path">
                                            <input type="hidden"  name="pbrand.id">
                                        </a>
                                    </div>
                                </div>
                                <div class="col-sm-9">
                                    <div class="col-sm-10">
                                        <label class="col-sm-3 control-label" style="text-align: right">标题:</label>
                                        <div class="col-sm-9">
                                            <input id="title" name="pbrand.title" class="form-control">
                                        </div>
                                        <label class="col-sm-3 control-label" style="text-align: right">链接:</label>
                                        <div class="col-sm-9">
                                            <input id="url" name="pbrand.url" class="form-control">
                                        </div>
                                        <label class="col-sm-3 control-label" style="text-align: right">排序:</label>
                                        <div class="col-sm-9">
                                            <input id="sort" name="pbrand.sort" class="form-control">
                                        </div>
                                    </div>
                                    <div class="col-sm-2 paddingnone text-right">
                                        <a href="javascript:void(0);" class="btn btn-danger martopcancel" onclick="delList('1')" target="_self">删除</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/demo/form-validate-demo.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/layer2.4/layer.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/ajaxfileupload.js"></script>

<script>
    var count=1;
    var index=1;
    var picPath='<%=Global.getConfig("OSSURL")%>';
    document.onkeydown=function(event){
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if(e && e.keyCode==27){ // 按 Esc
            //要做的事情
        }
        if(e && e.keyCode==113){ // 按 F2
            //要做的事情
        }
        if(e && e.keyCode==13){ // enter 键
            //要做的事情
            getPro();
        }
    };

    $(function () {
        loadWxReply();
    })

    function uploadFile(obj, id, picId) {//上传图片
        var labid = "";
        $.ajaxFileUpload({
            url: '${pageContext.request.contextPath}/common/doUploadFile.ac',
            secureuri: false,
            type: 'post',
            fileElementId: obj,
            dataType: 'json',
            success: function (data, status) {
                $("#" + id).attr("src", picPath + data.path);
                $("#" + picId).val(data.path);

            },
            error: function (data, status, e) {
                alert(e);
            }
        });
    }

    function addList() {
        if(count>=8){
            alert("最多设置8组");
        }else{
            count++;
            index++;
            var html='';
            html+=' <div class="col-sm-12 mainmidlist" id="div'+index+'">'+
                '                            <div class="col-sm-3">'+
                '                                <div class="dtupload">'+
                '                                    <a href="javascript:" class="upload_pic" style="height:80px;"><input type="file" name="fileToUpload" id="fileToUpload'+index+'" onChange="uploadFile(\'fileToUpload'+index+'\',\'imgUpdate'+index+'\',\'shopPicId'+index+'\');">'+
                '                                        <img id="imgUpdate'+index+'" src="${OSSURL}/common/plus_72.png" width="100%"/>'+
                '                                        <input type="hidden" id="shopPicId'+index+'" name="pbrand.path">'+
                '                                        <input type="hidden"  name="pbrand.id">'+
                '                                    </a>'+
                '                                </div>'+
                '                            </div>'+
                '                              <div class="col-sm-9">'+
                '                                  <div class="col-sm-10">'+
                '                                    <label class="col-sm-3 control-label" style="text-align: right">标题:</label>'+
                '                                    <div class="col-sm-9">'+
                '                                        <input id="title" name="pbrand.title" class="form-control"></input>'+
                '                                    </div>'+
                '                                    <label class="col-sm-3 control-label" style="text-align: right">链接:</label>'+
                '                                    <div class="col-sm-9">'+
                '                                        <input id="url" name="pbrand.url" class="form-control"></input>'+
                '                                    </div>'+
                '                                    <label class="col-sm-3 control-label" style="text-align: right">排序:</label>'+
                '                                    <div class="col-sm-9">'+
                '                                        <input id="sort" name="pbrand.sort" class="form-control"></input>'+
                '                                    </div>'+
                '                                  </div>'+
                '                                    <div class="col-sm-2 paddingnone text-right">'+
                '                                        <a href="javascript:void(0);" class="btn btn-danger martopcancel" onclick="delList(\''+index+'\')" target="_self">删除</a>'+
                '                                    </div>'+
                '                                  </div>'+
                '                              </div>';
            $("#divForm").append(html);
        }
    }

    function  delList(i) {
        if(count<=1){
            alert("最少保留1组");
        }else{
            count--;
            $("#div"+i).remove();
        }
    }


    function doSave() {
        $("#count").val(count);
        $.ajax( {
            url:'${pageContext.request.contextPath}/orderStatistics/doSaveReply.ac',// 跳转到 action
            type:'post',
            data:$("#form").serialize(),
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.flag=="true") {
                    alert("操作成功！");
                }else {
                    alert(data.msg);
                }
            },
            error : function() {
                alert("操作失败！");
            }
        });
    }


    function loadWxReply() {
        $.ajax( {
            url:'${pageContext.request.contextPath}/orderStatistics/loadWxReply.ac',// 跳转到 action
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data!=null){
                    count--;
                    var html='';
                    for(var i=0;i<data.length;i++){
                        index++;
                        count++;
                        html+=' <div class="col-sm-12 mainmidlist" id="div'+index+'">'+
                            '                            <div class="col-sm-3">'+
                            '                                <div class="dtupload">'+
                            '                                    <a href="javascript:" class="upload_pic" style="height:80px;"><input type="file" name="fileToUpload" id="fileToUpload'+index+'" onChange="uploadFile(\'fileToUpload'+index+'\',\'imgUpdate'+index+'\',\'shopPicId'+index+'\');">'+
                            '                                        <img id="imgUpdate'+index+'" src="${OSSURL}/'+data[i].path+'" width="100%"/>'+
                            '                                        <input type="hidden" id="shopPicId'+index+'" name="pbrand.path" value="'+data[i].path+'">'+
                            '                                        <input type="hidden">'+
                            '                                    </a>'+
                            '                                </div>'+
                            '                            </div>'+
                            '                              <div class="col-sm-9">'+
                            '                                  <div class="col-sm-10">'+
                            '                                    <label class="col-sm-3 control-label" style="text-align: right">标题:</label>'+
                            '                                    <div class="col-sm-9">'+
                            '                                        <input id="title" name="pbrand.title" value="'+data[i].title+'" class="form-control"></input>'+
                            '                                    </div>'+
                            '                                    <label class="col-sm-3 control-label" style="text-align: right">链接:</label>'+
                            '                                    <div class="col-sm-9">'+
                            '                                        <input id="url" name="pbrand.url" value="'+data[i].url+'"  class="form-control"></input>'+
                            '                                    </div>'+
                            '                                    <label class="col-sm-3 control-label" style="text-align: right">排序:</label>'+
                            '                                    <div class="col-sm-9">'+
                            '                                        <input id="sort" name="pbrand.sort" value="'+data[i].sort+'" class="form-control"></input>'+
                            '                                    </div>'+
                            '                                  </div>'+
                            '                                    <div class="col-sm-2 paddingnone text-right">'+
                            '                                        <a href="javascript:void(0);" class="btn btn-danger martopcancel" onclick="delList(\''+index+'\')" target="_self">删除</a>'+
                            '                                    </div>'+
                            '                                  </div>'+
                            '                              </div>';
                    }
                    $("#divForm").html(html);
                }

            },
            error : function() {
                alert("操作失败！");
            }
        });
    }

</script>

</body>

</html>

